package org.hawk.gwtppc.webtest.tests.classsuite;

import java.lang.reflect.Modifier;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.SubClassMock2;

public class GetDeclaredMethodTest implements Test {

	public void run() throws Throwable {
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue").toString(), 
				"public void org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue()");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue").getModifiers(), Modifier.PUBLIC);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue").getReturnType(), void.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue").getParameterTypes().length, 0);

		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class).toString(), 
				"protected final int org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue(int)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class).getModifiers(), Modifier.PROTECTED | Modifier.FINAL);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class).getReturnType(), int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class).getParameterTypes().length, 1);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class).getParameterTypes()[0], int.class);
		
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).toString(), 
				"java.lang.Object org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue(int,java.lang.Object)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).getModifiers(), 0);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).getReturnType(), Object.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).getParameterTypes().length, 2);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).getParameterTypes()[0], int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class).getParameterTypes()[1], Object.class);
		
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).toString(), 
				"private static org.hawk.gwtppc.webtest.tests.mock.SubClassMock2 org.hawk.gwtppc.webtest.tests.mock." +
						"SubClassMock2.processValue(int,java.lang.Object,org.hawk.gwtppc.webtest.tests.mock.SubClassMock2)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getModifiers(), Modifier.PRIVATE | Modifier.STATIC);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getReturnType(), SubClassMock2.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getParameterTypes().length, 3);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getParameterTypes()[0], int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getParameterTypes()[1], Object.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethod("processValue", int.class, Object.class, SubClassMock2.class).getParameterTypes()[2], SubClassMock2.class);
	}

	public String getName() {
		return "getDeclaredMethod(String, Class)";
	}

}
